<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Function</title>
<style type="text/css">
	body {background-color: white; color: black; font-family:sans-serif; font-size:medium;}
	a:link {color: #3300ff;}
	a:visited {color: #663399;}
	a:hover {color:#0099ff;}
	a:active {color: #0066cc;}
	a.button {text-decoration:none;}
	
	table.nav  {background-color: #dbddff;}
	table.body {margin-top:2ex; margin-bottom:2ex;}
	table.programlistingindent {margin-left:32px;}
	
	img { margin-bottom:0px; margin-top:0px;}
	tt {margin-left:0.5em; margin-right:0.5em; font-weight:lighter;}
	
	p {margin-top:0ex;}
	p.synopsis {margin-left:32px;}
	p.programlistingindent {margin-left:32px;}
	p.citetitle {margin-left:2em;}
	
	ul ul {list-style-type:square;}
	ul li p {margin-top:0ex; margin-bottom:.5ex; padding:0}
	ol li p {margin-top:0ex; margin-bottom:.5ex; padding:0}
	
	h1.reftitle {color:#a90000;}
	h1.reftitle {font-size:3.7ex; margin-top:0; margin-bottom:0; font-weight:bold}
	h1.title {color:black; font-size:4ex; margin-top:1ex; font-weight:bold}
	h2.title {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:3ex}
	h3.title {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2.5ex}
	h4.title {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2ex}
	h2 {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2.5ex}
	h3 {color:#bd0000; margin-top:1ex; margin-bottom:.9ex; font-weight:bold; font-size:2ex} 
	
	pre.programlisting {margin-left:32px;}
	pre.synopsis {margin-left:32px;}
	
	
	.categorytitle {margin-top:8px; padding-top:0px;}
	.categorylist {background-color: #e1e6f2;}
 	</style>
</head>
<body>
<a name="top_of_page"></a><p style="font-size:1px;"></p>
<h1 class="reftitle">Function</h1>
<h2>Purpose</h2>
<p>Function representation for MPT</p>
<h2>Syntax</h2>
<pre class="synopsis">F = Function(@fun, data)</pre>
<pre class="synopsis">F = Function(@fun)</pre>
<pre class="synopsis">F = Function([],struct('p',2))</pre>
<h2>Description</h2>
<p></p>
        The <tt>Function</tt> class represents functions handles that are associated to sets in MPT. The class
        combines the <tt>function_handle</tt> with changeable parameters which allows 
        specifications of very general functions. When constructing the <tt>Function</tt> object, the
        correctness of the given function is not tested. It is up to the user to provide correct mapping, or test 
        it via <tt>feval</tt> method for <tt>ConvexSet</tt> class.
        Domain of the function is specified by the set it is associated to. If the point lies outside of the domain,
        an error is thrown. 
        The range of the function is not known at the time of the construction of the <tt>Function</tt> object. It 
        can be determined after evaluation of the related function for given point.
        User can associate any data with the function, including parameters of the function, under the <tt>Data</tt>
        field. These data can be modified anytime after the construction of the object.
	<h2>Input Arguments</h2>
<table cellspacing="0" class="body" cellpadding="4" border="0" width="100%">
<colgroup>
<col width="31%">
<col width="69%">
</colgroup>
<tbody>
<tr valign="top">
<td><tt>Handle</tt></td>
<td>
<p></p>A <tt>function_handle</tt> that represents the function. It can be an anonymous function, e.g.
            <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function1.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function1.png"> that corresponds to syntax <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function2.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function2.png"> or it can be a link to another file that
            evaluates the expression, i.e. <tt>@file</tt>. Both of the expressions are fine as long as the given 
            handle can be evaluated at the time of the construction. 
            If more arguments (or parameters) are present in the function, the arguments are separated with a comma, 
            e.g. <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function3.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function3.png"> corresponds to <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function4.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function4.png">. For more info about 
            constructing handles see help for <tt>function_handle</tt> class.
        <p>
	    		Class: <tt>function_handle</tt></p>
</td>
</tr>
<tr valign="top">
<td><tt>Data</tt></td>
<td>
<p></p>Any data related to the function. It can be function parameters, variable bounds, domain, range, 
            measured data, symbolic representation, etc. The data can be changed after construction of the 
        <tt>Function</tt> object. </td>
</tr>
</tbody>
</table>
<h2>Output Arguments</h2>
<table cellspacing="0" class="body" cellpadding="4" border="0" width="100%">
<colgroup>
<col width="31%">
<col width="69%">
</colgroup>
<tbody><tr valign="top">
<td><tt>F</tt></td>
<td>
<p></p> 
         <tt>Function</tt> object. <p>
	    		Class: <tt>Function</tt></p>
</td>
</tr></tbody>
</table>
<h2>Example(s)</h2>
<h3>Example 
				1</h3>Construct empty <tt>Function</tt>
      <pre class="programlisting">F=Function</pre>
<pre class="programlisting">Empty Function
</pre>Construct an 5x1 array of empty <tt>Function</tt> objects <pre class="programlisting">F(5,1) = Function</pre>
<pre class="programlisting">Array of 5 Functions.
</pre>
<h3>Example 
				2</h3>Construct anonymous function <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function5.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function5.png">
      <pre class="programlisting"> F = Function(@(x,y) (x-y)/(x^2+y^2)^0.5) </pre>
<pre class="programlisting">Function: @(x,y)(x-y)/(x^2+y^2)^0.5
</pre>
<h3>Example 
				3</h3> Construct anonymous function <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function6.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function6.png"> with parameters <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function7.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function7.png"> and <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function8.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function8.png">. Firstly, construct empty <tt>Function</tt> object and put the parameter values inside the <tt>Data</tt> field<pre class="programlisting"> F = Function([],struct('a',10.4,'b',-0.56)) </pre>
<pre class="programlisting">Empty Function
</pre> Secondly, set the handle pointing to the parameters stored inside <tt>Data</tt> property <pre class="programlisting"> F.setHandle(@(x) F.Data.a*sin(F.Data.b*x)) </pre>
<pre class="programlisting">Function: @(x)F.Data.a*sin(F.Data.b*x)
</pre> The values of the parameters <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function9.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function9.png">, <img src="../../../../../../fig/mpt/modules/geometry/functions/@Function/function10.png" alt="../../../../../../fig/mpt/modules/geometry/functions/@Function/function10.png"> can be modified after construction of the object.
        The <tt>Function</tt> object will then take the new values of the parameters. <pre class="programlisting"> F.Data.a = 12.78; F.Data.b = -0.93 </pre>
<pre class="programlisting">Function: @(x)F.Data.a*sin(F.Data.b*x)
</pre>
<h3>Example 
				4</h3> For functions arrays you must correctly refer to the appropriate index of the function data  Allocate an array of <tt>Function</tt> objects <pre class="programlisting"> F(2,1) = Function </pre>
<pre class="programlisting">Array of 2 Functions.
</pre> Assign the data <pre class="programlisting"> F(1).Data = struct('a',-1,'b',2); </pre>
<pre class="programlisting"></pre>
<pre class="programlisting"> F(1).setHandle(@(x) F(1).Data.a*sin(F(1).Data.b*x)); </pre>
<pre class="programlisting"></pre>
<pre class="programlisting"> F(2).Data = struct('a',-3,'b',4); </pre>
<pre class="programlisting"></pre>
<pre class="programlisting"> F(2).setHandle(@(x) F(2).Data.a*sin(F(2).Data.b*x)); </pre>
<pre class="programlisting"></pre>
<h2>See Also</h2>
<a href="../@AffFunction/afffunction.html">afffunction</a>, <a href="../@QuadFunction/quadfunction.html">quadfunction</a>, <a href="./sethandle.html">sethandle</a><p></p>
<table class="nav" summary="Navigation aid" border="0" width="100%" cellpadding="0" cellspacing="0"><tr valign="top">
<td align="left" width="20">
<a href="horzcat.html" class="button">&#9664;</a>  </td>
<td align="left">horzcat</td>
<td>  </td>
<td align="right">mpt</td>
<td align="right" width="20"><a href="../../../../../mpt.html" class="button">&#9654;</a></td>
</tr></table>
<br><p>©  <b>2010-2013</b>     Martin Herceg: ETH Zurich,    <a href="mailto:herceg@control.ee.ethz.ch">herceg@control.ee.ethz.ch</a></p>
</body>
</html>
